package com.egg.ylt.activity;

import android.os.Bundle;
import android.view.View;

import com.egg.ylt.R;
import com.egg.ylt.Utils.Constants;
import com.egg.ylt.Utils.CustomUtils;
import com.egg.ylt.Utils.StatusBarUtil;
import com.egg.ylt.pojo.UserPhotoListEntity;
import com.egg.ylt.widget.imagepicker.ImagesDataHolder;
import com.egg.ylt.widget.imagepicker.PreviewAdapter;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.view.ViewPagerFixed;
import com.yonyou.framework.library.base.BaseActivity;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.common.CommonUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created By Dlx
 * on 2019/2/24
 */
public class ACT_MultiBigPhotos extends BaseActivity {

    @BindView(R.id.multipic_viewpager)
    ViewPagerFixed mViewPager;
    private PreviewAdapter mAdapter;
    private List<String> imageUrls = new ArrayList<>();
    private List<UserPhotoListEntity.ListBean> growthStampPicList;
    private int mCurrentPosition = 0;
    private ImagesDataHolder imagesDataHolder;
    public static int RECORD_ENTERTYPE = 1;
    public static int GROWTH_STAMP_ENTERTYPE = 2;
    private int enterType = 0;


    @Override
    protected boolean isApplyKitKatTranslucency() {
        return false;
    }

    @Override
    protected void getBundleExtras(Bundle extras) {

    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.act_multi_bigphotos;
    }

    @Override
    protected View getLoadingTargetView() {
        return null;
    }

    @Override
    protected void initViewsAndEvents() {
        StatusBarUtil.transparencyBar(this);
        enterType = getIntent().getIntExtra(Constants.ENTER_TYPE, 0);
        imagesDataHolder = ImagesDataHolder.getInstance();
        growthStampPicList = imagesDataHolder.getEntityList();
        imageUrls = imagesDataHolder.getImageUrlList();
        if (enterType == GROWTH_STAMP_ENTERTYPE) {
            sortBeanIntoString();
        }
        mAdapter = new PreviewAdapter(this, imageUrls);
        mCurrentPosition = getIntent().getIntExtra(ImagePicker.EXTRA_SELECTED_IMAGE_POSITION, 0);
        mViewPager.setAdapter(mAdapter);
        mViewPager.setCurrentItem(mCurrentPosition, false);
    }

    private void sortBeanIntoString() {
        for (UserPhotoListEntity.ListBean bean : growthStampPicList) {
            imageUrls.add(bean.getImageUrl());
        }
    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    @Override
    protected boolean isBindEventBusHere() {
        return false;
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return false;
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return null;
    }

    @Override
    public void showBusinessError(ErrorBean error) {

    }
}
